$import([ "com.hh.message.main.OrgAndUserList",
		"com.hh.message.main.LxrUserList" ]);
Ext.define('com.hh.message.main.MainMessageWindow', {
	extend : 'com.hh.base.BaseWindow',
	title : '消息工具',
	width : 300,
	height : BrowserContext.getBrowserHeight() - 80,
	x : BrowserContext.getBrowserWidth() - 400,
	layout : 'border',
	constructor : function(config) {
		this.config = config || {};
		this.superclass.constructor.call(this, this.config);
		this.init();

		var cylxrsPanel = Ext.create("com.hh.message.main.LxrUserList", {
			rightMenuItems : [ {
				iconCls : 'delete',
				text : '删除常用联系人',
				handler : function() {
					var record = cylxrsPanel.tree.getSelectionModel()
							.getSelection();
					if (record == null) {
						ExtFrame.info("请选择人员！");
					} else {
						Request.synRequestObject('usersystem-user-deleteCylxr',
								{
									'paramsMap.cylxrid' : record[0].get("id")
								});
						cylxrsPanel.tree.getStore().load();
					}
				}
			} ]
		});

		var orgTreePanel = Ext.create("com.hh.message.main.OrgAndUserList", {
			rightMenuItems : [ {
				iconCls : 'add',
				text : '添加到常用联系人',
				handler : function() {
					var record = orgTreePanel.tree.getSelectionModel()
							.getSelection();
					if (!record[0].get('leaf')) {
						ExtFrame.info("请选择人员！");
					} else {
						var user = Ext.decode(record[0].get("id"));
						Request.synRequestObject('usersystem-user-addCylxr', {
							'paramsMap.cylxrid' : user.userid
						});
						cylxrsPanel.tree.getStore().load();
					}
				}
			} ]
		});

		var form = Ext.create('Ext.panel.Panel', {
			title : '      ',
			icon : '/common/images/icons/comment.png',
			layout : {
				type : 'accordion',
				animate : true
			},
			items : [ {
				title : '常用联系人',
				border : false,
				// autoScroll : true,
				iconCls : 'user',
				layout : 'fit',
				items : [ cylxrsPanel ]
			}, {
				title : '组织机构',
				// autoScroll : true,
				border : false,
				icon : '/common/images/extjsico/application_group.png',
				layout : 'fit',
				items : [ orgTreePanel ]
			}, {
				title : '我的消息',
				// autoScroll : true,
				border : false,
				icon : '/common/images/icons/comment.png',
				html : 'dddd'
			} ]
		});

		var mainTab = Ext.create("com.hh.base.BaseTabPanel", {
			padding : '1',
			region : 'center'
		});

		mainTab.add(form);
		mainTab.setActiveTab(form);

		this.panel.add(mainTab);
	}
});